<?php namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Region extends Model {

    protected $table = 'sysregion';
    protected $primaryKey = 'sysRegionId';
    protected $guarded  = ['sysRegionId'];
    public $timestamps = false;

    public function poster(){
        return $this->belongsTo('App\User', 'inputMan');
    }

    public function father(){
        return $this->belongsTo('App\Region','superiorRegion');
    }

    public function hasFather($id = 0){
        return "" == DB::table('sysregion')->where('sysRegionId',$id)->first() ? false : true;
    }
}
